package com.lj.back.manage.scaffold.module.job.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lj.back.manage.scaffold.module.job.DO.ScheduleJobLogDO;
import com.lj.back.manage.scaffold.module.job.DTO.ScheduleJobLogDTO;
import com.lj.back.manage.scaffold.module.job.DTO.ScheduleJobLogPageQuery;
import com.lj.back.manage.scaffold.module.job.DTO.ScheduleJobLogStatisticsDTO;
import com.lj.back.manage.scaffold.module.job.dao.ScheduleJobLogDao;
import com.lj.back.manage.scaffold.module.job.service.ScheduleJobLogService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lv
 */
@Service
@AllArgsConstructor
public class ScheduleJobLogServiceImpl extends ServiceImpl<ScheduleJobLogDao,ScheduleJobLogDO> implements ScheduleJobLogService {

    private final ScheduleJobLogDao scheduleJobLogDao;

    /**
     * 分页查询定时任务日志列表
     * @param pageQuery 分页查询对象
     * @return
     */
    @Override
    public IPage<ScheduleJobLogDTO> listScheduleJobLog(ScheduleJobLogPageQuery pageQuery){
        Page<ScheduleJobLogDO> pageBean = new Page<>(pageQuery.getCurrent(),pageQuery.getSize());
        IPage<ScheduleJobLogDTO> page = scheduleJobLogDao.selectPageScheduleJobLog(pageBean,pageQuery);
        return page;
    }

    /**
     * 获取统定时任务计信息列表
     * @param jobId
     * @return
     */
    @Override
    public List<ScheduleJobLogStatisticsDTO> listScheduleJobLogStatistics(String jobId){
        List<ScheduleJobLogStatisticsDTO> scheduleJobLogStatistics = scheduleJobLogDao.selectScheduleJobLogStatistics(jobId);
        return scheduleJobLogStatistics;
    }
}
